package com.j180.spring_jwt_demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration
@EnableSwagger2// 打开swagger的支持
public class SwaggerConfig {

    //一个Docket可以认为是一个模块
    @Bean
    public Docket userDocket(){
        Docket docket = new Docket(DocumentationType.SWAGGER_2);
        //设置api模块
        docket.groupName("用户模块");
        //设置模块的信息
        docket.apiInfo(userApiInfo());
        //设置模块要扫描的包
        docket.select()
                //配置需扫描生成api的位置
                .apis(RequestHandlerSelectors.basePackage("com.j180.spring_jwt_demo.controller"))
                .paths(PathSelectors.any()) //过滤路径
                .build();//构建api模块
        return docket;
    }

    @Bean
    public ApiInfo userApiInfo(){
         //创建一个联系人
        Contact contact = new Contact("j180", "http://www.j180.com", "1234j180@163.com");

        ApiInfo userApiInfo = new ApiInfo("用户的Api接口",
                                 "该接口是测试登录或者xxxx操作",
                                 "V1.0",
                                 "http://www.j180.com",
                                  contact,
                          "j180版本", "http://www.j180.com/ss", new ArrayList());

        return userApiInfo;
    }



}

